, NAME and ADDRESS are
string constants. When you register your schema with the ontology, such
constants become part of the vocabulary of the ontology.
Schemata that describe concepts support inheritance (this is not true for
all other schemata, e.g., predicates, actions, etc.). You can define the
concept Man as a refinement of the concept Person:
ConceptSchema manSchema = new ConceptSchema(MAN);
manSchema.addSuperClass(personSchema);
Each element schema can be associated with a Java class to map elements of
the ontology that comply with a schema with Java objects of that class. The
following is a class that might be associated with the Person
schema:
public class Person extends Concept {
private String name = null;
private Address address = null;
public void setName(String name) {
this.name = name;
}
public void setAddress(Address address) {
this.address = address;
}
public String getName() {
return name;
}
public Address getAddress() {
return address;
}
}
When sending/receiving messages you can represent your content in terms of
objects belonging to classes that the ontology associates with schemata.
As the previous example suggests, you cannot use objects of class
Person when asking for the value of some attribute, e.g., when
asking for the value of address. Basically, the problem is that
you cannot 'assign' a variable to an attribute of an object, i.e.,
you cannot write something like:
person.setName(new Variable("X")).
In order to solve this problem, you can describe your content in terms of
abstract descriptors. An abstract descriptor is an
object that reifies an element of the ontology.
The following is the definition of the abstract
descriptor for the concept Person:
AbsConcept absPerson = new AbsConcept(MAN);
absPerson.setSlot(NAME, "John");
absPerson.setSlot(ADDRESS, absAddress);
where absAddress is the abstract descriptor for the Mary's
address:
AbsConcept absAddress = new AbsConcept(ADDRESS);
absAddress.setSlot(CITY, "London");
Objects of class Ontology allows you to:
- register schemata with associated (i) a mandatory terms of the
vocabulary and, e.g.,
NAME (ii) an optional Java class,
e.g., Person;
- retrieve the registered information through various keys.
The framework provides two ontologies that you can use for building your
application-specific ontologies:
BasicOntology: that provides all basic elements, i.e.,
primitive data types, aggregate types, etc.
ACLOntology: that extends the BasicOntology to
provide the elements that the semantics of the FIPA ACL mandates, e.g.,
the Done modality, variables with an associated
cardinality, etc.
Application-specific ontologies should be implemented extending the
ACLOntology.
- Author:
- Federico Bergenti - Universita` di Parma
- See Also:
Concept,
jade.content.abs.Concept,
ACLOntology,
BasicOntology,
ConceptSchema
|
Constructor Summary |
Ontology(java.lang.String name)
Construct an ontology with a given name |
Ontology(java.lang.String name,
Ontology base)
Construct an ontology with a given name that extends
base. |
|
Method Summary |
abstract void |
add(ObjectSchema schema)
Adds a schema to the ontology |
abstract void |
add(ObjectSchema schema,
java.lang.Class javaClass)
Adds a schema to the ontology and associates it to the class
javaClass |
abstract AbsObject |
fromObject(java.lang.Object obj)
Converts an object to an abstract descriptor. |
abstract java.lang.Class |
getClass(java.lang.String name)
Retrieves the concrete class associated with name in
the vocabulary. |
java.lang.String |
getName()
Retrieves the name of the ontology. |
abstract ObjectSchema |
getSchema(java.lang.Class javaClass)
Retrieves the schema associated with javaClass |
abstract ObjectSchema |
getSchema(java.lang.String name)
Retrieves the schema associated with name. |
abstract java.lang.Object |
toObject(AbsObject abs)
Converts an abstract descriptor to an object. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
base
protected Ontology base
name
protected java.lang.String name
Ontology
public Ontology(java.lang.String name)
- Construct an ontology with a given
name
- Parameters:
name - identifier of the ontology.
Ontology
public Ontology(java.lang.String name,
Ontology base)
- Construct an ontology with a given
name that extends
base.
- Parameters:
name - identifier of the ontology.base - base ontology.
getName
public java.lang.String getName()
- Retrieves the name of the ontology.
- Returns:
- the name of the ontology.
add
public abstract void add(ObjectSchema schema)
throws OntologyException
- Adds a schema to the ontology
- Parameters:
schema - the schema to add- Throws:
- OntologyException -
add
public abstract void add(ObjectSchema schema,
java.lang.Class javaClass)
throws OntologyException
- Adds a schema to the ontology and associates it to the class
javaClass
- Parameters:
schema - the schema.javaClass - the concrete class.- Throws:
- OntologyException -
getSchema
public abstract ObjectSchema getSchema(java.lang.String name)
throws OntologyException
- Retrieves the schema associated with
name.
- Parameters:
name - the name of the schema in the vocabulary.- Returns:
- the schema.
- Throws:
- OntologyException -
getSchema
public abstract ObjectSchema getSchema(java.lang.Class javaClass)
throws OntologyException
- Retrieves the schema associated with
javaClass
- Parameters:
javaClass - the Java class- Returns:
- the schema
- Throws:
- OntologyException -
getClass
public abstract java.lang.Class getClass(java.lang.String name)
throws OntologyException
- Retrieves the concrete class associated with
name in
the vocabulary.
- Parameters:
name - the name of the schema.- Returns:
- the Java class.
- Throws:
- OntologyException -
toObject
public abstract java.lang.Object toObject(AbsObject abs)
throws OntologyException,
UngroundedException
- Converts an abstract descriptor to an object.
- Parameters:
abs - the abstract descriptor.- Returns:
- the object
- Throws:
- OntologyException -
- UngroundedException -
- See Also:
fromObject(Object)
fromObject
public abstract AbsObject fromObject(java.lang.Object obj)
throws OntologyException
- Converts an object to an abstract descriptor.
- Parameters:
obj - the object- Returns:
- the abstract descriptor.
- Throws:
- OntologyException -
- See Also:
toObject(AbsObject)